/**
 * 团购新房详情对话框
 */
var HouseGroupCheck = {
    id: "housegroupcheckTable",//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
HouseGroupCheck.initColumn = function () {
    var columns = [
        {field: 'selectItem', radio: true},
        {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '申请人', field: 'user_name', align: 'center', valign: 'middle', sortable: true},
        {title: '团购人数', field: 'group_num', align: 'center', valign: 'middle', sortable: true},
        {title: '申请日期', field: 'create_time', align: 'center', valign: 'middle', sortable: true}];
    return columns;
};

/**
 * 检查是否选中
 */
HouseGroupCheck.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        HouseGroupCheck.seItem = selected[0];
        return true;
    }
};

/**
 * 点击审核按钮时
 * @param userId 管理员id
 */
HouseGroupCheck.openHouseCheck = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '团购新房申请审核',
            area: ['900px', '650px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/housegroupcheck/view/' + this.seItem.id
        });
        this.layerIndex = index;
    }
};

HouseGroupCheck.resetSearch = function () {
    $("#user_name").val("");
    $("#beginTime").val("");
    $("#endTime").val("");

    HouseGroupCheck.search();
}

HouseGroupCheck.search = function () {
    var queryData = {};

    queryData['user_name'] = $("#user_name").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();

    HouseGroupCheck.table.refresh({query: queryData});
}

$(function () {
    var defaultColunms = HouseGroupCheck.initColumn();
    var table = new BSTable("housegroupcheckTable", "/housegroupcheck/list", defaultColunms);
    table.setPaginationType("client");
    HouseGroupCheck.table = table.init();
});
